package com.woniuxy.member.app.apiImpl;

import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.member.app.apiImpl.util.RequestUtil;
import com.woniuxy.member.client.MemberResevationQueryClient;

import com.woniuxy.reservation.client.param.SearchReservationByConditionParam;
import com.woniuxy.reservation.client.reservationclient.ReservationQueryClient;
import com.woniuxy.reservation.client.result.ReservationClientDto;
import com.woniuxy.store.client.StoreInfoClient;
import common.WoniuPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;
@RequestMapping("/member")
@RestController
public class MemberResevationQueryApiImpl implements MemberResevationQueryClient {
    @Autowired
    private ReservationQueryClient reservationQueryClient;
    @Autowired
    private StoreInfoClient storeInfoClient;
    @Log("查询自己的预约")
    @Override
    public Result getReservationByMemberId() {
        SearchReservationByConditionParam searchReservationByConditionParam = new SearchReservationByConditionParam();
        searchReservationByConditionParam.setStoreId(RequestUtil.getStoreId());
        searchReservationByConditionParam.setMemberId(RequestUtil.getMemberId());
        Result<WoniuPage<ReservationClientDto>> result = reservationQueryClient.searchReservationByCondition(searchReservationByConditionParam);
        for (ReservationClientDto reservationClientDto : result.getData().getList()) {
            reservationClientDto.setStoreName(storeInfoClient.getInfoById(reservationClientDto.getStoreId()).getData().getStoreName());
        }
        return result;
    }
}
